package com.hxx.common.core.wcontour.read;

import com.hxx.common.core.wcontour.base.TrainData;
import com.hxx.common.core.wcontour.util.GridRarefyUtil;

import java.io.File;
import java.io.IOException;

/**
 * 气象温度工具类
 *
 * @author hxd
 */
public class TempJsonUtil {

    /**
     * 点数抽稀倍数
     */
    private static final int rarefy = 1;

    public static TrainData readJson(File jsonFile) throws IOException {
        // 标准JSON读取
        TrainData trainData = GridJsonUtil.read(jsonFile);
        int width = trainData.getSize()[0], height = trainData.getSize()[1];
        double[][] data = trainData.getData();
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                // 转温度
                data[i][j] = data[i][j] - 273.15;
            }
        }
        GridRarefyUtil.rarefy(trainData, rarefy);
        return trainData;
    }

    
}
